$(document).ready(function () {
    layui.use('form', function () {
        var form = layui.form;
        form.render();

        getDevice();

    });
});

function getDevice() {

    var id = $('#id').val();

    ajax(
        "/admin/device/getDevice", "POST",
        { deviceId: id }
        ,true, true, false
    ).done(function (returnData) {

        $("input[name='deviceId']").val(returnData.deviceId);
        $("input[name='deviceName']").val(returnData.deviceName);
        $("input[name='deviceNo']").val(returnData.deviceNo);
        $("input[name='deviceManufacturer']").val(returnData.deviceManufacturer);
        $("input[name='devicePrice']").val(returnData.devicePrice);
        $("input[name='deviceStartTime']").val(returnData.deviceStartTime);
        $("input[name='deviceStatusString']").val(returnData.deviceStatusString);
        $("input[name='createUserName']").val(returnData.createUserName);
        $("input[name='repairUserName']").val(returnData.repairUserName);
        $(":radio[name='deviceStatus'][value='" + returnData.deviceStatus + "']").prop("checked", true);
        form.render();

    });

}

function editDevice() {

    var formJSON = $("#device-submit-form").serializeObject();

    // 编辑设备
    ajax(
        "/admin/device/editDevice", "POST",
        formJSON, true, true, true
    ).done(function () {
        loadingPage("/admin/device/device");
    });

}